package com.heima.media.controller;

import com.heima.common.dto.ResponseResult;
import com.heima.media.dto.ChannelDto;
import com.heima.media.entity.WmChannel;
import com.heima.media.service.IWmChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/channel")
@Api(tags = "频道管理API")
public class WmChannelController {

    @Autowired
    private IWmChannelService wmChannelService;

    /**
     * 分页模糊查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation(value = "listByName", notes = "根据频道名称分页查询")  // value指名称  notes 备注
    @ApiImplicitParam(name = "dto",dataType = "ChannelDto",required = true)
    public ResponseResult listByName(@RequestBody ChannelDto dto) {
        return wmChannelService.listByName(dto);
    }

    /**
     * 新增频道
     * @param channel
     * @return
     */
    @PostMapping()
    @ApiOperation(value = "saveChannel", notes = "新增频道")  // value指名称  notes 备注
    @ApiImplicitParam(name = "channel",dataType = "WmChannel",required = true)
    public ResponseResult saveChannel(@RequestBody WmChannel channel){
        return wmChannelService.saveChannel(channel);
    }

}
